<?php
/** 
 * Script permettant d'intégrer n'importe quelle police dans un environnemnet web 
 * 
 * @author Damien Cuvillier <damien.cuvillier@gmail.com> - Mamadou Celoudara
 * @since Avril 2011
 * @licence Apache 2.0 
 */
 
if(!isset($_GET["font"])){
	die("No font specified");
}
$font = $_GET["font"];

$fontDir = dirname($_SERVER["SCRIPT_FILENAME"]) . "/font/" ;
$fontUrl = "http://" . $_SERVER["SERVER_NAME"] . substr($_SERVER["REQUEST_URI"], 0, strrpos($_SERVER["REQUEST_URI"], "/") +1). $fontDir ;


if(!is_file($fontDir . $font . ".ttf")){
	die("Font $font is not available in TTF format");
}
if(!is_file($fontDir . $font . ".eot")){
	die("Font $font is not available in EOT format");
}

$name = isset($_GET["name"]) ? $_GET["name"] : $font;

$fontDir = "font/" ;
$fontUrl = "http://" . $_SERVER["SERVER_NAME"] . substr($_SERVER["REQUEST_URI"], 0, strrpos($_SERVER["REQUEST_URI"], "/") +1). $fontDir ;
header("Content-Type: text/css" ) ;

if(preg_match("/MSIE/i", getenv("HTTP_USER_AGENT"))) :
	/* Internet Explorer */
?>
@font-face {
	font-family: '<?php echo $name ?>';
	font-style: normal;
	font-weight: 100;
	src: url('./font.php?f=<?php echo $font ?>&t=eot');
}
<?php 
else:
?>
@font-face {
	font-family: '<?php echo $name ?>';
	font-style: normal;
	font-weight: 100;
	src: url('./font.php?f=<?php echo $font ?>&t=ttf') format('truetype');
}
<?php 
endif;
